<html>
<head>
    <meta charset="UTF-8">
    <title>用户中心</title>
    <link rel="stylesheet" type="text/css" href="css/common.css"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <link rel="stylesheet" type="text/css" href="css/mylessons.css"/>
    <script type="text/javascript" src="js/libs/modernizr.min.js"></script>
    <style type="text/css">
     input,button{font: 12px/1.14 "Arial","Hiragino Sans GB",\5b8b\4f53,"Georgia","serif";color: #333;outline: 0;height:28px;}
     select{height:30px;}
    </style> 
</head>
<body>
<div class="topbar-wrap white">
    <!--<div class="topbar-inner clearfix">-->
    <div></div><div></div><div></div>
        <div class="topbar-logo-wrap clearfix">
            <h1 class="topbar-logo none"><a href="index.html" class="navbar-brand">用户中心</a></h1>
        </div>
    </div>
</div>
<div class="container clearfix">
    <div class="sidebar-wrap">
        <div class="sidebar-title">
            <h1>菜单</h1>
        </div>
        <div class="sidebar-content">
            <ul class="sidebar-list">
                <li>
                    <a href="#"><i class="icon-font">&#xe003;</i>常用操作</a>
                    <ul class="sub-menu">
                        <li><a href="customer-myguest.php"><i class="icon-font">&#xe005;</i>我的留言</a></li>
                        <li><a href="customer-preson.php"><i class="icon-font">&#xe006;</i>个人信息</a></li>
                        <li><a href="customer-guest.php"><i class="icon-font">&#xe008;</i>开始留言</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="index.html">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">我的留言</span></div>
        </div>
        <div class="search-wrap">
        </div>
            <form name="myform" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                        <?php
                            session_start();
                            header("Content-Type:text/html;charset=UTF-8");
                            if (isset($_SESSION['id'])) {
                                echo "欢迎".$_SESSION['name']."登录！";
                                echo "<a href='login.html?'logout=logout>注销</a>";
                                $username = $_COOKIE['name'];
                                $password = $_COOKIE['password'];
                                //echo $username,$password;
                                include "shuju.php";
                                $id = $_SESSION['id'];
                                $sql = "select * from ly where uid = '$id'";
                                $db = new DB();
                                $res = $db->get($sql);
                            }else{
                                header("location:login.html");
                            }

                         ?>

                                    <?php 
                                    for ($i=1; $i <= count($res); $i++) { 
                                    ?> 
                                        <form action="customer-myguest.php" method="get">   
                                            <table class="insert-tab" width="95%">
                                    <?php   
                                        $str = $res[$i-1][4];
                                        $id = $res[$i-1][0];
                                        echo "<tr>
                                        <td>留言内容$i:</td>
                                        <td><input type='text' value='$str' name='con'></td>
                                        <td><input type='submit' value='更改留言' name='upd' class='btn btn-primary btn3 mr10'></td>
                                        <td><input type='submit' value='删除留言' name='del' class='btn btn-danger btn3 mr10'></td>
                                        </tr>
                                        <input type='hidden' name='oo' value='$id'>";
                                    ?>  
                                     </table>
                                    </form>
                                    <?php
                                        }
                                    ?>

                       
                    </div>
                </div>
            </form>
             <?php 

                                    if (isset($_GET['upd'])) {
                                            $content = $_GET['con'];
                                            $id = $_GET['oo'];
                                            //echo $content;
                                            $db = new DB();
                                            $sql = "update ly set content = '$content' where id = '$id'";
                                            $upd = $db->update($sql);
                                            //var_dump($upd);
                                            echo "<script>alert('更新成功');location.href='".$_SERVER["HTTP_REFERER"]."';</script>";
                                    }
                        ?>
                        <?php 
                            //include 'shuju.php';
                                    if (isset($_GET['del'])) {
                                            $content = $_GET['con'];
                                            $id = $_GET['oo'];
                                            //echo $content;
                                            $db = new DB();
                                            $sql = "delete from ly where id = '$id'";
                                            echo $sql;
                                            $upd = $db->delete($sql);
                                            //var_dump($upd);
                                            echo "<script>alert('删除成功');location.href='".$_SERVER["HTTP_REFERER"]."';</script>";
                                    }
                        ?>
    </div>
    <!--/main-->
</div>
</body>
</html>